package hu.bme.mit.mdsd.csipetcsapat.appstore.core;

import java.util.Iterator;

/*
 * AccessModerator class for handling role access to services 
 */
public class AccessModerator {
	/*
 	 * Determines if the user has access to a service
 	 */
	public static boolean hasAccess(User user, String serviceName) {
		Iterator<Role> it = user.getRoles().iterator();
		while(it.hasNext()){
			if(RoleDispatcher.getRole(RoleDispatcher.RoleName.valueOf(it.next().getName())).getServices().contains(serviceName)){
				return true;
			}
		}
		return false;
	}
}
